package com.yygo.model;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by tiansha on 2015/6/30.
 */
@Entity
@Table(name = "activity")
public class Activity extends BaseObject {
    private static final long serialVersionUID = -222323267022967222L;
    private Long id;
    private String operator;
    private String role;
    private Date time;
    private String activity;
    private LoanRequest loanRequest;

    public Activity(){}

    public Activity(String operator, String activity) {
        time = new Date();
        this.operator = operator;
        this.activity = activity;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(length = 20)
    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    @Column(length = 20)
    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    @Column
    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    @Column
    public String getActivity() {
        return activity;
    }

    public void setActivity(String activity) {
        this.activity = activity;
    }

    @ManyToOne
    @JoinColumn(name="req_id")
    public LoanRequest getLoanRequest() {
        return loanRequest;
    }

    public void setLoanRequest(LoanRequest loanRequest) {
        this.loanRequest = loanRequest;
    }


    @Override
    public String toString() {
        return "Activity: " + id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Bank)) {
            return false;
        }

        final Activity activity = (Activity) o;

        return !(id != null ? !id.equals(activity.getId()) : activity.getId() != null);
    }

    @Override
    public int hashCode() {
        return id.intValue();
    }
}
